﻿using Sustainalytics.BusinessResearchProductStates.Entities.ResearchState;
using Sustainalytics.Entities.SustainableProducts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sustainalytics.Entities.ProductInvolvement
{
    public class ProductInvolvementFrameworkInternal
    {
        public virtual Guid IndicatorId { get; set; }
        public virtual string IndicatorSymbol { get; set; }
        public virtual string IndicatorSymbolDescription { get; set; }
        public virtual Guid CategoryId { get; set; }
        public virtual string CategorySymbol { get; set; }
        public virtual bool HasLevelOfInvolvement { get; set; } // (revenue range)
        public virtual PILevelOfInvolvement LevelOfInvolvement { get; set; }
        public virtual List<ClientFacingProduct> ClientFacingProducts { get; set; }
        public virtual string CategoryOfInvolvementType { get; set; }

        public virtual bool HasOwnershipPercent { get; set; }
        public virtual double OwnershipPercent { get; set; }
        public virtual string StandardAnalysis { get; set; }
        public virtual List<PIDataSource> Sources { get; set; }
        public virtual DateTime LastEdited { get; set; }
        public virtual int Score { get; set; }
        
        public virtual string CategoryOfInvolvementDescription { get; set; }
        public virtual string RangeOwnership { get; set; }
        public virtual decimal? RevenuePercentage { get; set; }
        public virtual decimal? ProductRevenue { get; set; }
        public virtual string ProductInvolvementAnalysis { get; set; }
        public virtual string RevenueAnalysis { get; set; }
        public virtual string RevenueAnalysisSource { get; set; }
        public virtual int FinancialYear { get; set; }

        public ProductInvolvementDataIndicator ToPIIndicatorAssessment()
        {
            switch (CategoryOfInvolvementType)
            {
                case ProductInvolvement.CategoryOfInvolvementType.Yes:
                    return new ProductInvolvementDataIndicator
                    {
                        IndicatorId = IndicatorId,
                        IndicatorSymbol = IndicatorSymbol,
                        IndicatorSymbolDescription = IndicatorSymbolDescription,
                        CategoryId = CategoryId,
                        CategorySymbol = CategorySymbol,
                        HasLevelOfInvolvement = HasLevelOfInvolvement,
                        LevelOfInvolvement = LevelOfInvolvement,
                        ClientFacingProducts = ClientFacingProducts,
                        CategoryOfInvolvementType = CategoryOfInvolvementType,
                        CategoryOfInvolvementDescription = CategoryOfInvolvementDescription,
                        HasOwnershipPercent = HasOwnershipPercent,
                        OwnershipPercent = OwnershipPercent,
                        RangeOwnership = RangeOwnership,
                        StandardAnalysis = StandardAnalysis,
                        Sources = Sources,
                        LastEdited = LastEdited,
                        Score = Score
                    };
                case ProductInvolvement.CategoryOfInvolvementType.NotResearched:
                    return new ProductInvolvementDataIndicator
                    {
                        IndicatorId = IndicatorId,
                        IndicatorSymbol = IndicatorSymbol,
                        IndicatorSymbolDescription = IndicatorSymbolDescription,
                        CategoryId = CategoryId,
                        CategorySymbol = CategorySymbol,
                        ClientFacingProducts = ClientFacingProducts,
                        CategoryOfInvolvementType = CategoryOfInvolvementType,
                        CategoryOfInvolvementDescription = CategoryOfInvolvementDescription
                    };
                case ProductInvolvement.CategoryOfInvolvementType.No:
                default:
                    return null;
            }
        }

        public SustainableProductsIndicator ToPIIndicatorSolution()
        {
            switch (CategoryOfInvolvementType)
            {
                case ProductInvolvement.CategoryOfInvolvementType.Yes:
                    return new SustainableProductsIndicator
                    {
                        IndicatorSymbol = IndicatorSymbol,
                        CategorySymbol = CategorySymbol,
                        HasLevelOfInvolvement = HasLevelOfInvolvement,
                        LevelOfInvolvement = LevelOfInvolvement,
                        ClientFacingProducts = ClientFacingProducts,
                        CategoryOfInvolvementType = CategoryOfInvolvementType,
                        Sources = Sources,
                        CategoryOfInvolvementDescription = CategoryOfInvolvementDescription,
                        RangeOwnership = RangeOwnership,
                        RevenuePercentage = RevenuePercentage,
                        ProductRevenue = ProductRevenue,
                        ProductInvolvementAnalysis = ProductInvolvementAnalysis,
                        RevenueAnalysis = RevenueAnalysis,
                        RevenueAnalysisSource = RevenueAnalysisSource,
                        FinancialYear = FinancialYear
                    };
                case ProductInvolvement.CategoryOfInvolvementType.NotResearched:
                    return new SustainableProductsIndicator
                    {
                        IndicatorSymbol = IndicatorSymbol,
                        CategorySymbol = CategorySymbol,
                        ClientFacingProducts = ClientFacingProducts,
                        CategoryOfInvolvementType = CategoryOfInvolvementType
                    };
                case ProductInvolvement.CategoryOfInvolvementType.No:
                default:
                    return null;
            }
        }
    }
}
